<<<<<<< HEAD
<template>
    <div>


        <span class="demonstration" style="margin-left: 20px;margin-right: 0px;">单据日期：</span>
        <el-date-picker v-model="cashChange.orderDate" align="right" type="date" placeholder="选择日期"
            :picker-options="pickerOptions" @change="handleDateChange" style="margin-left: 10px;"></el-date-picker>
        <div style="float: right; margin-top:  0px;">


            <span style="margin-left: 10px;">单据编号：</span>
            <el-input style="width: 120px;margin-left: 10px;margin-right: 20px;" placeholder=""
                v-model="cashChange.changeNum" clearable disabled>
            </el-input>

            <el-dropdown>
                <span class="el-dropdown-link">
                    <i class="el-icon-edit"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>SKDYYYYMMDD</el-dropdown-item>
                    <el-dropdown-item>狮子头</el-dropdown-item>
                    <el-dropdown-item>螺蛳粉</el-dropdown-item>
                    <el-dropdown-item disabled>双皮奶</el-dropdown-item>
                    <el-dropdown-item divided>蚵仔煎</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
        <hr style="margin-top: 10px;">
        <div style="clear: both"></div>

        <div style="clear: both;"></div>
        <div style="margin-top: 10px;float: right">
            <el-button @click="add()">保存</el-button><el-button type="success">审核</el-button><el-button
                type="warning">反审核</el-button><el-button type="primary">提交</el-button>
        </div>
        <div style="clear: both;"></div>

        <el-table height="300px" :data="tableData" border style="width: 100%; font-size: 13px;margin-top: 10px">
            <el-table-column fixed label="" width="50">
                <i class="el-icon-circle-plus-outline" style="margin-left: 8px;" @click="addRow()"></i>
                <br>
                <i class="el-icon-remove-outline" style="margin-left: 8px;"></i>
            </el-table-column>
            <el-table-column label="转出账户" width="150">
                <template slot-scope="scope">
                    <el-select v-model="scope.row.accountOutId" placeholder="转出账户" style="width: 100px;">
                        <el-option v-for="item in accounts" :key="item.accountId" :label="item.accountName"
                            :value="item.accountId">
                        </el-option>
                    </el-select>
                </template>
            </el-table-column>
            <el-table-column label="转入账户" width="140">
                <template slot-scope="scope">
                    <el-select v-model="scope.row.accountInId" placeholder="转入账户" style="width: 100px;">
                        <el-option v-for="item in accounts" :key="item.accountId" :label="item.accountName"
                            :value="item.accountId">
                        </el-option>
                    </el-select>
                </template>
            </el-table-column>
            <el-table-column label="金额" width="140">
                <template slot-scope="scope">
                    <el-input v-model="scope.row.money" style="width: 100px;margin-left: 10px;margin-right: 20px;"
                        placeholder="金额" clearable>
                    </el-input>
                </template>
            </el-table-column>
            <el-table-column label="结算方式" width="140">
                <template slot-scope="scope">
                    <el-select v-model="scope.row.clearMethod" placeholder="结算方式" style="width: 110px;">
                        <el-option v-for="item in clearMethods" :key="item.clearId" :label="item.clearName"
                            :value="item.clearId">
                        </el-option>
                    </el-select>
                </template>
            </el-table-column>
            <el-table-column label="备注" width="260">
                <template slot-scope="scope">
                    <el-input v-model="scope.row.remark" style="width: 200px;margin-left: 10px;margin-right: 20px;"
                        placeholder="备注" clearable>
                    </el-input>
                </template>
            </el-table-column>
        </el-table>
        <div style="width: 100%;background-color: blanchedalmond;height: 30px;">
            <table style="width: 78.7%;height: 30px;">
                <tr>
                    <td style="width: 50%;">合计：</td>
                    <td style="width: 50%;">123</td>
                </tr>
            </table>
        </div>
        <el-input v-model="cashChange.remark" type="textarea" :rows="2" placeholder="暂无备注信息"
            style="width: 100%;line-height: 20px;margin-top: 10px">

        </el-input>
        <span style="float: right;margin-right: 20px;margin-top: 10px;">
            <el-button @click="goto('CashChangeHistory')">历史单据</el-button><el-button>操作日志</el-button>
        </span>
    </div>

</template>

<script>
import axios from 'axios';
import Top from './Top.vue';

export default {
    name: "WriteOff",
    components:
    {
        Top
    },
    data() {
        return {
            id: "",
            dialogFormVisible: false,
            choose: false,
            choose1: false,
            path: "",
            accounts: "",
            clearMethods: "",
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > Date.now();
                },
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        picker.$emit('pick', new Date());
                    }
                }, {
                    text: '昨天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', date);
                    }
                }, {
                    text: '一周前',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', date);
                    }
                }]
            },
            cashChange: {
                changeNum: "",
                orderDate: "",
                remark: "",
            },
            tableData: [{
                accountInId: '',
                accountOutId: '',
                money: '',
                clearMethod: '',
                remark: ''
            }],
            value1: '',
            value2: '',
        };
    },
    methods: {

        add: function () {
            const reg = /^([1-9]\d*(\.\d{1,2})?|0\.\d{1,2})$/
            for (const contact of this.tableData) {
                if (contact.accountInId === "") {
                    alert("请选择转入账户")
                    return
                }
                if (contact.accountOutId === "") {
                    alert("请选择转出账户")
                    return
                }
                if (contact.money === "") {
                    alert("请填写收款金额")
                    return
                }
                if (isNaN(contact.money)) {
                    alert("收款金额必须为数字")
                    contact.money
                    return
                }
                if (!reg.test(contact.money)) {
                    alert("收款金额不符合规范")
                    return
                }
            }
            if (this.cashChange.orderDate === "") {
                alert("请选择日期")
                return
            }
            // if(this.cashChange.changeNum===""){
            //     alert("订单编号为空")
            //     return
            // }
            console.log(this.cashChange)
            console.log(this.tableData)
            const formData = new FormData();
            formData.append("cashChange", JSON.stringify(this.cashChange))
            formData.append('list', JSON.stringify(this.tableData));
            axios.post(
                "/cash/change/insert",
                formData,
                {
                    headers: {
                        'Content-Type': 'application/json'
                    }
                }
            ).then(rs => {
                console.log(rs)
                if (rs.data.code === 200) {
                    alert("保存成功")
                } else {
                    alert("保存失败")
                }
            })
        },
        getClearMethod: function () {
            this.axios({
                url: "/info/clear/selectAll",
            }).then(rs => {
                // alert("1")
                this.clearMethods = rs.data.list
                console.log(this.clearMethods)
            })
        },
        getAccounts: function () {
            this.axios({
                url: "/info/account/selectAll",
                params: {

                }
            }).then(rs => {
                console.log(rs)
                this.accounts = rs.data.accounts
            })
        },
        handleDateChange(value) {
            // value 即为选中的日期值
            console.log('选中的日期是：', value);
            this.orderDate = value
            // 在这里可以执行更多的逻辑，比如更新数据、调用 API 等
        },
        addRow: function () {
            this.tableData.push({
                accountInId: '',
                accountOutId: '',
                money: '',
                clearMethod: '',
                remark: ''
            })
        },
        goto() {
            this.$router.push(this.path)
        },
        goto(to) {
            this.$router.push(to)
        }
    },
    created: function () {
        this.id = this.$route.query.id;
        alert(this.id)
        this.getAccounts()
        this.getClearMethod()

    }
}
</script>

<style>
tr {
    border: 1px solid black;
}
=======
<template>
    <div>


        <span class="demonstration" style="margin-left: 20px;margin-right: 0px;">单据日期：</span>
        <el-date-picker v-model="value2" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions"
            style="width: 120px;">
        </el-date-picker>
        <div style="float: right; margin-top:  0px;">


            <span style="margin-left: 10px;">单据编号：</span>
            <el-input style="width: 120px;margin-left: 10px;margin-right: 20px;" placeholder="" v-model="input"
                clearable disabled>
            </el-input>

            <el-dropdown>
                <span class="el-dropdown-link">
                    <i class="el-icon-edit"></i>
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>SKDYYYYMMDD</el-dropdown-item>
                    <el-dropdown-item>狮子头</el-dropdown-item>
                    <el-dropdown-item>螺蛳粉</el-dropdown-item>
                    <el-dropdown-item disabled>双皮奶</el-dropdown-item>
                    <el-dropdown-item divided>蚵仔煎</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
        <hr style="margin-top: 10px;">
        <div style="clear: both"></div>

        <div style="clear: both;"></div>
        <div style="margin-top: 10px;float: right">
            <el-button>保存</el-button><el-button type="success">审核</el-button><el-button
                type="warning">反审核</el-button><el-button type="primary">提交</el-button>
        </div>
        <div style="clear: both;"></div>

        <el-table height="300px" :data="tableData" border style="width: 100%; font-size: 13px;margin-top: 10px">
            <el-table-column fixed label="" width="50"> </el-table-column>
            <el-table-column fixed label="转出账户" width="150">
                <el-select v-model="value" placeholder="转出账户" style="width: 100px">
                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-table-column>
            <el-table-column label="转入账户" width="140">
                <el-select v-model="value" placeholder="转出账户" style="width: 100px">
                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-table-column>
            <el-table-column label="金额" width="140">
                <el-input style="width: 100px; margin-left: 10px; margin-right: 20px" placeholder="金额" v-model="input"
                    clearable>
                </el-input>
            </el-table-column>
            <el-table-column label="结算方式" width="140">
                <el-select v-model="value" placeholder="结算方式" style="width: 100px">
                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
                    </el-option>
                </el-select>
            </el-table-column>
            <el-table-column label="结算号" width="300">
                <el-input style="width: 250px; margin-left: 10px; margin-right: 20px" placeholder="备注" v-model="input"
                    clearable>
                </el-input>
            </el-table-column>
            <el-table-column label="备注" width="160">
                <el-input style="width: 118px; margin-left: 10px; margin-right: 20px" placeholder="在线交易号"
                    v-model="input" clearable>
                </el-input>
            </el-table-column>
        </el-table>
        <div style="width: 100%;background-color: blanchedalmond;height: 30px;">
            <table style="width: 78.7%;height: 30px;">
                <tr>
                    <td style="width: 50%;">合计：</td>
                    <td style="width: 50%;">123</td>
                </tr>
            </table>
        </div>
        <el-input type="textarea" :rows="2" placeholder="暂无备注信息" v-model="textarea"
            style="width: 100%;line-height: 20px;margin-top: 10px">

        </el-input>
        <span style="float: right;margin-right: 20px;margin-top: 10px;">
            <el-button @click="goto('CashChangeHistory')">历史单据</el-button><el-button>操作日志</el-button>
        </span>
    </div>

</template>

<script>
import Top from './Top.vue';

export default {
    name: "WriteOff",
    components:
    {
        Top
    },
    data() {
        return {
            dialogFormVisible: false,
            choose: false,
            choose1: false,
            path: "",
            options: [{
                value: '选项1',
                label: '黄金糕'
            }, {
                value: '选项2',
                label: '双皮奶'
            }, {
                value: '选项3',
                label: '蚵仔煎'
            }, {
                value: '选项4',
                label: '龙须面'
            }, {
                value: '选项5',
                label: '北京烤鸭'
            }],
            gridData: [{
                date: '2016-05-02',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1518 弄'
            }, {
                date: '2016-05-04',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1518 弄'
            }, {
                date: '2016-05-01',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1518 弄'
            }, {
                date: '2016-05-03',
                name: '王小虎',
                address: '上海市普陀区金沙江路 1518 弄'
            }],
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > Date.now();
                },
                shortcuts: [{
                    text: '今天',
                    onClick(picker) {
                        picker.$emit('pick', new Date());
                    }
                }, {
                    text: '昨天',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24);
                        picker.$emit('pick', date);
                    }
                }, {
                    text: '一周前',
                    onClick(picker) {
                        const date = new Date();
                        date.setTime(date.getTime() - 3600 * 1000 * 24 * 7);
                        picker.$emit('pick', date);
                    }
                }]
            },
            tableData: [{
                date: '2016-05-02',
                name: '王小虎',
                province: '上海',
                city: '普陀区',
                address: '上海市普陀区金沙江路 1518 弄',
                zip: '200333'
            }, {
                date: '2016-05-04',
                name: '王小虎',
                province: '上海',
                city: '普陀区',
                address: '上海市普陀区金沙江路 1517 弄',
                zip: '200333'
            }, {
                date: '2016-05-01',
                name: '王小虎',
                province: '上海',
                city: '普陀区',
                address: '上海市普陀区金沙江路 1519 弄',
                zip: '200333'
            }, {
                date: '2016-05-03',
                name: '王小虎',
                province: '上海',
                city: '普陀区',
                address: '上海市普陀区金沙江路 1516 弄',
                zip: '200333'
            }],

            value1: '',
            value2: '',
        };
    },
    methods: {
        goto() {
            this.$router.push(this.path)
        },
        goto(to) {
            this.$router.push(to)
        }
    }

}
</script>

<style>
tr {
    border: 1px solid black;
}
>>>>>>> 6be95d2b3200ab6fbb17d1e0a5a9b367f780cc8e
</style>